{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import ipywidgets as widgets\n",
    "from ipywidgets import interact\n",
    "# import pandas as pd\n",
    "# import plotly.express as px\n",
    "# pd.options.plotting.backend = \"plotly\"\n",
    "\n",
    "from ipywidgets import interact, interactive, fixed, interact_manual\n",
    "import ipywidgets as widgets\n",
    "from IPython.display import display\n",
    "\n",
    "out = widgets.Output()\n",
    "out"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "@out.capture()\n",
    "def function_with_captured_output():\n",
    "    print('First output widget')\n",
    "\n",
    "function_with_captured_output()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "out2 = widgets.Output()\n",
    "caption = widgets.Label(value='Label Widget')\n",
    "textbox = widgets.Text()\n",
    "widgets.link((caption, 'value'), (textbox, 'value'))\n",
    "\n",
    "@out.capture()\n",
    "def function_with_captured_output():\n",
    "    display(out2)\n",
    "    display(caption)\n",
    "    display(textbox)\n",
    "    # Output a custom mime type instead of a plotly plot so that we don't have to install plotly on CI.\n",
    "    display({\"application/vnd.custom\": f\"Custom Mime Output under the `output widget`\"}, raw=True)\n",
    "    # df = pd.DataFrame({\"x\": list(range(10)), \"y\": list(range(10))})\n",
    "    # fig = df.plot.scatter(x=\"x\", y=\"y\")\n",
    "    # fig.show()\n",
    "\n",
    "\n",
    "function_with_captured_output()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "@out2.capture()\n",
    "def function_with_captured_output2():\n",
    "    print('Second output widget')\n",
    "\n",
    "function_with_captured_output2()"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
